package com.cool.service.impl;

import com.cool.dao.ParkinglotMapper;
import com.cool.entity.Parkinglot;
import com.cool.service.ParkinglotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class ParkinglotServiceImpl implements ParkinglotService {
    @Autowired
    public ParkinglotMapper mapper;

    public int insert(Parkinglot record){
        return mapper.insert(record);
    }

    public ArrayList<Parkinglot> selectAll(){
        return mapper.selectAll();
    }

    public int addSurplus(Parkinglot record){
            if(record.getSurplus()==record.getSpace()) return -1;
            else return mapper.addSurplus(record);
    }
    public int subSurplus(Parkinglot record){
        if(record.getSurplus()==0) return -1;
        else return mapper.subSurplus(record);
    }
    public Parkinglot selectById(int id){
        return mapper.selectByPrimaryKey(id);
    }
}
